#设置CMAKE最低版本
CMAKE_MINIMUM_REQUIRED(VERSION 3.13)

CMAKE_POLICY(SET CMP0048 NEW)
CMAKE_POLICY(SET CMP0074 NEW)

#设置项目名称
SET(PROJECT_NAME qiniu)
#建立项目
PROJECT(${PROJECT_NAME} VERSION 7.1.3 LANGUAGES C)

set(CMAKE_C_STANDARD 99)

IF(WIN32)
    ADD_COMPILE_OPTIONS("$<$<C_COMPILER_ID:MSVC>:/utf-8>")
    ADD_COMPILE_OPTIONS("$<$<CXX_COMPILER_ID:MSVC>:/utf-8>")
ENDIF()

AUX_SOURCE_DIRECTORY(b64 DIR_SRCS_B64)
AUX_SOURCE_DIRECTORY(cJSON DIR_SRCS_CJSON)
AUX_SOURCE_DIRECTORY(qiniu DIR_SRCS_QINIU)
MESSAGE(STATUS "Src file: ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_QINIU}")
#编译可执行程序
#ADD_EXECUTABLE(${PROJECT_NAME} ${DIR_SRCS})
#如果要生成静态链接库
ADD_LIBRARY(${PROJECT_NAME}_static STATIC ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_QINIU})
#如果要生成动态链接库
ADD_LIBRARY(${PROJECT_NAME} SHARED ${DIR_SRCS_B64} ${DIR_SRCS_CJSON} ${DIR_SRCS_QINIU})
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
FIND_PACKAGE(CURL REQUIRED)
IF(NOT "${CURL_INCLUDE_DIRS}" STREQUAL "")
    INCLUDE_DIRECTORIES("${CURL_INCLUDE_DIRS}")
ENDIF()
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ${CURL_LIBRARIES})
FIND_PACKAGE(OpenSSL REQUIRED)
IF(NOT "${OPENSSL_INCLUDE_DIR}" STREQUAL "")
    INCLUDE_DIRECTORIES("${OPENSSL_INCLUDE_DIR}")
ENDIF()
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ${OPENSSL_LIBRARIES})

ADD_SUBDIRECTORY(gtests)
ADD_SUBDIRECTORY(examples)
